
const state = {
  sidebar: false,
  device: 'desktop',
  activeMenu:'systemmanage',
  isTest:true,  //当前是否使用测试数据，没有后台情况下为true
  currentTheme:'default',
}

const mutations = {
  TOGGLE_SIDEBAR: state => {
    state.sidebar = !state.sidebar
  },
  TOGGLE_DEVICE: (state, device) => {
    state.device = device
  },
  SET_ACTIVE_MENU: (state, menu) => {
    state.activeMenu = menu;
  },
//更新主题
  TOGGLE_THEME(state,theme){
    state.currentTheme = theme;
    sessionStorage.setItem('currentTheme',theme);
  },
}

const actions = {
  toggleSideBar({ commit }) {
    commit('TOGGLE_SIDEBAR')
  },
  toggleDevice({ commit }, device) {
    commit('TOGGLE_DEVICE', device)
  },
  setActiveMenu({ commit }, menu) {
    commit('SET_ACTIVE_MENU', menu)
  },
  //更新主题
  updateTheme({ commit }, theme){
    commit('TOGGLE_THEME', theme);
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
